using System;

namespace PhillyCodeCamp.Domain.Validation
{
    [AttributeUsage(AttributeTargets.Property)]
    public class MandatoryAttribute : ValidationAttribute
    {
        public MandatoryAttribute()
            : this("is mandatory")
        {
        }

        public MandatoryAttribute(string errMessage)
        {
            _message = errMessage;
        }

        protected override bool validate(object target, object rawValue)
        {
            if (rawValue == null)
            {
                return true;
            }
            return (rawValue.ToString().Length > 0);
        }
    }
}